﻿using System.Reactive;
using Autofac;
using ReactiveUI.Fody.Helpers;
using ScienceAIApp.ViewModels.AlertViewModel;

namespace ScienceAIApp.ViewModels;
public class FirstScreenLeftMenuViewModel : ScienceBaseViewModel
{
    private HistorySeriesDescriptionViewModel _historySeriesDescription;
    private AiToolBarViewModel _aiToolBar;


    [Reactive] public ScienceBaseViewModel ToolBarViewModel { get; set; }
    [Reactive] public SeriesDescriptionViewModel SeriesDescriptionViewModel { get; set; }

    public FirstScreenLeftMenuViewModel(SeriesDescriptionViewModel seriesDescription,
        HistorySeriesDescriptionViewModel historySeriesDescription,
        AiToolBarViewModel aiToolBar)
    {
        _historySeriesDescription = historySeriesDescription;
        _aiToolBar = aiToolBar;

        ToolBarViewModel = aiToolBar;
        SeriesDescriptionViewModel = seriesDescription;

        SeriesDescriptionViewModel.ChooseDicomSeriesInteraction.RegisterHandler(async ctx =>
        {
            await using var scope = AppIoc.AppContainer.BeginLifetimeScope();
            var alertVm = scope.ResolveOptional<SeriesChooseViewModel>()!;
            alertVm.SetSplitSeriesInfoList(ctx.Input);

            AppEnvironment.Instance.AlertWindow.SetAlertViewModel(alertVm);
            AppEnvironment.Instance.AlertWindow.Show();
            ctx.SetOutput(Unit.Default);
        });
    }
}
